component{
	include "../../inc/lib.cfm"; 

	public any function list(rc){
		
		var result = {};
		var offset = (rc.page-1)*rc.rows;
		hql = "from adsmaterial where " & rc.sqlWhere & rc.sqlSort;
		var result["rows"] = ormExecuteQuery(hql, false, {maxResults=rc.rows, offset=offset});
		var totalhql = "select count(id) as total from adsmaterial where " & rc.sqlWhere ;
		var result["total"] = ormExecuteQuery(totalhql, true);
		
		return result;
	}

	public any function save(any rc){
		transaction {
            var q = entityNew("adsmaterial");
			include "../../inc/saveandupdate.cfm";
        }
        return q;
	}
	
	public any function delete(numeric id){
		var q = entityLoadByPk("adsmaterial", arguments.id);
		entityDelete(q);
		transactionCommit();
		return q;
	}
	
	public any function update(any rc){
		transaction {
            var q = entityLoadByPk("adsmaterial", rc.id);
			include "../../inc/saveandupdate.cfm";
        }
        return q;
	}
	
	public any function get(numeric id){
		result = entityLoadByPk("adsmaterial", arguments.id);
		return result;
	}
	
}